package com.kingsoft.demo.jdbc;

import java.sql.*;


public class TestC {

	public void test(){
		
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL","scott","tiger");
			DatabaseMetaData dm = con.getMetaData();
			System.out.println(dm.getDatabaseProductName());
			System.out.println(dm.getDatabaseProductVersion());
			System.out.println(dm.getDriverName());
			System.out.println(dm.getDriverVersion());
			
			
			
			con.close();						
			
		} catch (ClassNotFoundException e) {			
			e.printStackTrace();
		} catch (SQLException e) {			
			e.printStackTrace();
		}
		
	}
	
	public void test2(){
		
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/","root","admin");
			System.out.println(con);
			DatabaseMetaData dm = con.getMetaData();
			System.out.println(dm.getDatabaseProductName());
			System.out.println(dm.getDatabaseProductVersion());
			System.out.println(dm.getDriverName());
			System.out.println(dm.getDriverVersion());
			
			con.close();						
			
		} catch (ClassNotFoundException e) {			
			e.printStackTrace();
		} catch (SQLException e) {			
			e.printStackTrace();
		}
		
	}
	public static void main(String[] args) {
		new TestC().test();
	}
}
